home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / testNeXT2Mac.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  92 lines

  1. #import "NeXTToMacText.h"
  2. #import "common.h"
  3. #import <stdio.h>
  4.  
  5. void main()
  6. {
  7.     Instance    converter;
  8.     Integer    index;
  9.     Character    theChar, strictChar;
  10.     CString        source = "Hi there how are you doing?";
  11.     ErrorCode        errorone, errortwo;
  12.     FILE*    theFile;
  13.     CString    result, buffer;
  14.     Integer    resultsize;
  15.     Integer    ctr, colctr = 1;
  16.  
  17.     converter = [[NeXTToMacText alloc] init];
  18.     //
  19.     //    Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
  20.     //
  21.     theChar = [converter ConvertCharacter: 'A'];
  22.     errorone = [converter GetErrorCode];
  23.     printf("Character A: %c (bool result: %d)\n", theChar, errorone);
  24.  
  25.     theChar = [converter ConvertCharacter: 0xB6];
  26.     errorone = [converter GetErrorCode];
  27.     printf("Character paragraph: %c (bool result: %d)\n", theChar, errorone);
  28.  
  29.     theChar = [converter ConvertCharacter: 0xE6];
  30.     errorone = [converter GetErrorCode];
  31.     printf("Can't convert eth : %c  (bool result: %d)\n", theChar, errorone);
  32.  
  33.     for (index = 0; index < 256; index++)
  34.     {
  35.         theChar = [converter ConvertCharacter: index];
  36.         errorone = [converter GetErrorCode];
  37.         [converter ConvertSingleQuotes: YES];
  38.         strictChar = [converter ConvertCharacter: index];
  39.         errortwo = [converter GetErrorCode];
  40.         [converter ConvertSingleQuotes: NO];
  41.         printf("Converting NeXT 0x%X to Mac 0x%X (%c)  (error: %d) [quote mode: 0x%X (%c) (error: %d)]\n",
  42.             index,
  43.             theChar, theChar, errorone,
  44.             strictChar, strictChar, errortwo);
  45.     }
  46.  
  47.     // part two.
  48.     buffer = NewCString(512);
  49.     
  50.     for (ctr = 0; ctr < 256; ctr++)
  51.     {
  52.         if (colctr != 16)
  53.         {
  54.             buffer[ctr*2] = ctr;
  55.             buffer[(ctr*2)+1] = ' ';
  56.             colctr++;
  57.         }
  58.         else
  59.         {
  60.             buffer[ctr*2] = ctr;
  61.             buffer[(ctr*2)+1] = '\r';
  62.             colctr = 1;
  63.         }
  64.     }
  65.     buffer[512] = EndOfCString;
  66.     printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
  67.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 512];
  68.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  69.     printf("Size of result: %d\n", resultsize);
  70.     printf("Results text is: \n");
  71.     for (ctr = 0; ctr < resultsize; ctr ++)
  72.         printf("%c", result[ctr]);
  73.     printf("\n");
  74.     //    test that it expands its internal buffer alright by giving it some text which we
  75.     //    know will multiply in size when it comes out. .. convert lots of Thorns
  76.     for (ctr = 0; ctr < 16; ctr++)
  77.         buffer[ctr] = 0xFC;
  78.     buffer[16] = EndOfCString;
  79.     printf("Source text is: \n%s\n", (CString)buffer);
  80.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 16];
  81.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  82.     printf("Size of result: %d\n", resultsize);
  83.     printf("Results text is: \n");
  84.     for (ctr = 0; ctr < resultsize; ctr ++)
  85.         printf("%c", result[ctr]);
  86.     printf("\n");
  87.     
  88.     FreeCString(result);
  89.     FreeCString(buffer);
  90.     close(theFile);
  91.     [converter    free];
  92. }